{% extends 'EasyVoteBundle::layout.html.twig' %}

{% block title %}EasyVote | Elections{% endblock %}

{% block content %}
    {% if isProfileComplete == false %}
        <p class="text-center" style="background: #ff544a;color: #000;padding: 5px;"><span style="color: #FFF;"><strong>Alert:</strong></span>&nbsp;<a href="{{ path('profile_edit', {'id': user.id}) }}" style="color: #000;"><u>Please update your profile</u></a>.</p>
    {% endif %}
	<!-- Banner -->
	<div class="container-fluid">
		<div class="row">
			<div class="jumbotron" style="padding: 0;">
                {% image '@EasyVoteBundle/Resources/public/images/banner.png' output='/images/banner.png' %}
                <img src="{{ asset_url }}" class="img-responsive center-block">
                {% endimage %}
			</div>
		</div>
	</div>

	<!-- Elections Max 4 each row-->
	<div class="container">
		<div class="row row-centered">
			{% for election in elections %}
				<div class="col-md-3 col-centered">
					<div class="panel panel-default">
						<div class="panel-heading panel-title"><a href="elections/view/{{ election.id }}"><strong>{{ election.title }}</strong></a></div>
						<div class="container-fluid center-block" style="padding-top: 20px;">
							{# Election photo #}
                            <a href="elections/view/{{ election.id }}"><img src="{{ election.imageURL }}" height="200px" width="200px" class="center-block img-thumbnail"></a>
						</div>
						<div class="panel-body">
							{{ election.summary }}<br/><br/>
							<strong>Voting Start Date:</strong> {{ election.votingStartDate|date('m-d-Y') }}<br/>
							<strong>Voting End Date:</strong> {{ election.votingEndDate|date('m-d-Y') }}<br/>
							<strong>Voter Degree: </strong> 
							{% for degree in election.degrees%}
								{{ degree.displayName }} {% if degree != loop.last%}, {% endif %}
							{% endfor %} <br/>
							<strong>Voter Classification: </strong> 
							{% for classification in election.classifications%}
								{{ classification.name }} {% if classification != loop.last%}, {% endif %}
							{% endfor %}
						</div>		
						<div class="panel-footer text-center">
							<a href="elections/view/{{ election.id }}"><button class="btn btn-primary">View</button></a>&nbsp;
							{% if isAdmin %} {# Show administer if the user is an Admin #}
							<a href="elections/administer/{{ election.id }}"><button class="btn btn-primary">Edit</button></a>&nbsp;
							<a href="{{ path('elections_remove', {'id': election.id}) }}"><button class="btn btn-danger">Remove</button></a>
							{% endif %}
						</div>
					</div>
				</div>
			{% endfor %}
		</div>
	</div>

<!-- Fixed Bottom Navbar -->
<nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
<div class="container">
<div class="nav navbar-right pull-right">
{# If the user is an Admin, show the create new election button #}
{% if isAdmin %}
<a href="{{ path('elections_new') }}"><button class="btn navbar-btn btn-success">Add an Election</button></a>
{% endif %}
<button class="btn navbar-btn btn-danger" onclick="window.history.back()">Back</button>
</div>
</div>
</nav>
{% endblock %}
